<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    时资：<input type="text" id="rate"><br>
    工时：<input type="text" id="hour"><br>
    <input type="button" id="btn" value="计算">
    <input type="text" readonly id="res">
</body>
<script>
    // 1. 
    var rate = document.getElementById("rate")
    var hour = document.getElementById("hour")
    var btn = document.getElementById("btn")
    var res = document.getElementById("res")

    // 2. 
    btn.onclick = function(){
        // 3. 
        // 
        var r = rate.value-0;
        var h = hour.value-0;
        // 
        var s = 0;
        // 
        if(h > 40){
            s = 40*r + (h-40)*r*1.5;
        }else{
            s = h * r;
        }
        // 
        res.value = s;
    }
</script>
</html>